function TreeNode(val, left, right) {
    this.val =  (val === undefined) ? 0 : val 
    this.left =  (left === undefined) ? null : left 
    this.right =  (right === undefined) ? null : right 
}
function arrayToTree1 (arr) {
    if (!arr.length ||( arr.length && !arr.length[0])) return new TreeNode()
    
}
function arrayToTree(arr) {
    if (!arr || arr.length === 0) return null;
  
    const root = new TreeNode(arr[0]);
    const queue = [root];
    let i = 1;
  
    while (i < arr.length) {
      const node = queue.shift();
      if (i < arr.length && arr[i] !== null) {
        node.left = new TreeNode(arr[i]);
        queue.push(node.left);
      }
      i++;
      if (i < arr.length && arr[i] !== null) {
        node.right = new TreeNode(arr[i]);
        queue.push(node.right);
      }
      i++;
    }
  
    return root;
  }
export {
    TreeNode,
    arrayToTree
}